#include"String.h"

void string_test1()
{
	wjz::string s1("Hello World");
	cout << s1.c_str() << endl;
	for (int i = 0; i < s1.size(); i++)
	{
		cout << s1[i] << ' ';
	}
	cout << endl;

	wjz::string s2("Hello Wjz");
	//wjz::string::const_iterator cit = s2.begin();
	auto cit = s2.begin();
	while (cit != s2.end())
	{
		cout << *cit << ' ';
		cit++;
	}
	cout << endl;
}


void string_test2()
{
	wjz::string s1("Hello");
	s1.push_back(' ');
	cout << s1.c_str() << endl;
	s1.append("World");
	cout << s1.c_str() << endl;

	s1 += ' ';
	s1 += "ssssssssss";
	cout << s1.c_str() << endl;

}

void string_test3()
{
	wjz::string s1("Hello World");
	cout << s1.c_str() << endl;
	s1.resize(5);
	cout << s1.c_str() << endl;

	wjz::string s2("Hello World");
	s2.resize(20, 'x');
	cout << s2.c_str() << endl;

}

void string_test4()
{
	wjz::string s1("HelloWorld");
	s1.insert(5, 1, ' ');
	cout << s1.c_str() << endl;
	s1.insert(11, 10, 'x');
	cout << s1.c_str() << endl;

	wjz::string s2("Hello ");
	s2.insert(6, "World");
	cout << s2.c_str() << endl;
	s2.insert(11, "xxxxxxxxxxxxx");
	cout << s2.c_str() << endl;

	wjz::string s3("Hello world");
	s3.erase(5, 1);
	cout << s3.c_str() << endl;
	s3.erase(5, 5);
	cout << s3.c_str() << endl;
}

void string_test5()
{
	wjz::string s1("https://legacy.cplusplus.com/reference/cstring/strstr/?kw=strstr");
	int pos1 = s1.find("://", 0);
	cout << pos1 << endl;
	int pos2 = s1.find("/", pos1 + 3);
	cout << pos2 << endl;
	int pos3 = s1.find("/", pos2 + 1);
	cout << pos3 << endl;

	cout << s1.substr(0, pos1) << endl;
	cout << s1.substr(pos1 + 3, pos2 - pos1 - 3) << endl;
	cout << s1.substr(pos2 + 1, pos3 - pos2 - 1) << endl;

}

void string_test6()
{
	wjz::string s1("Hello World");
	cout << s1 << endl;
	wjz::string s2("hello");
	s2 += '\0';
	s2 += "xxxxxxxxxxx";
	cout << s2 << endl;
	wjz::string s3;
	cin >> s3;
	cout << s3 << endl;
}

void string_test7()
{
	//wjz::string s1("Hello World");
	//cout << s1.npos << endl;


}

int main()
{
	string_test7();
	return 0;
}